<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="./lib/layui-v2.5.5/css/layui.css"
	media="all">
<link rel="stylesheet" href="./css/public.css" media="all">
</head>
<body>
	<form class="layui-form">

<!-- 
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>收货人</label>
			<div class="layui-input-inline">
				<input type="text" name="userName" required lay-verify="required"
					placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>联系方式</label>
			<div class="layui-input-inline">
				<input type="text" name="phone" required lay-verify="required"
					placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div> -->

		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>省</label>
			<div class="layui-input-inline">
				<input type="text" name="province" required lay-verify="required"
					placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>市</label>
			<div class="layui-input-inline">
				<input type="text" name="city" required lay-verify="required"
					placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>县</label>
			<div class="layui-input-inline">
				<input type="text" name="county" required lay-verify="required"
					placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>用户ID</label>
			<div class="layui-input-inline">
				<input type="text" name="userID" required lay-verify="required"
					placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">*</span>详细地址</label>
			<div class="layui-input-inline">
				<input type="text" name="detAddress" required lay-verify="required"
					placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
		</div>



		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<script src="../houtai/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
	<script>
		//加载了layui的form模块
		layui.use([ 'form', 'upload' ], function() {
			var form = layui.form;
			var $ = layui.jquery; //引入jquery
			/* var upload = layui.upload;
			
			//执行实例
			  var uploadInst = upload.render({
			    elem: '#test1' //绑定元素
			    ,url: '/wk1un9/DessigonSerclet?method=upload' //上传接口
			    ,done: function(res){
			      //上传完毕回调
			      console.log(res);
			 $("#imgUrl").val('upload/'+res.data);
			 $("#imgFace").attr('src','/wk1un9/upload/'+res.data);
			    }
			    ,error: function(){
			      //请求异常回调
			    	 
			    }
			  }); */

			//监听提交
			form.on('submit(formDemo)', function(data) {
				var d = data.field; //表单中的数据，定义一个对象来接收
				//通过ajax向数据库提交数据了
				d.method = "add";
				console.log(d); //提交之前的一个数据验证、通过打印的方式先手动的去判断一下这个数据
				var url = '/wk1un10/houtai/receivingAdd';
				//确保数据没有问题就进行ajax提交了
				$.post(url, d, function(data) {
					if (data.count > 0) {
						console.log('添加成功');
						var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
						parent.layer.close(index); //关闭窗口
					}
				}, "json");
				return false;
			});
		});
	</script>
</body>
</html>